;;;;;;;;;;;;;;;;;;;;  dir plugins  ;;;;;;;;;;;;;;;;;;;;
(require 'dired+)
(require 'dired-details+)
(require 'dired-single)
(require 'dired-view)
(require 'dired-isearch)

;;;;;;;;;;;;;;;;;;;;  dir setting  ;;;;;;;;;;;;;;;;;;;;
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)

;;;;;;;;;;;;;;;;;;;;  dir function  ;;;;;;;;;;;;;;;;;;;;
;;;http://kid-dot-emacs.googlecode.com/svn-history/r14/trunk/50dired.el
(defmacro kid-dired-define-assoc-group (patterns actions &optional name)
  "define an assoc entry to help dired guess the shell command.
PATTERN is a list of regexps used to match the filename.
NAME is a list of string or expression which eval to a string
to denote what shell command to execute. Optional NAME is
the name of this group , just for documentation purpose."
  (let ((item (gensym)))
    `(dolist (,item ',patterns)
       (setq dired-guess-shell-alist-user
             (cons (list ,item ,@actions) dired-guess-shell-alist-user)))))


(defmacro kid-dired-define-sort (key switch)
  "define the key `s KEY' to sort use switch to ls."
  `(define-key dired-mode-map ,(concat "s" key)
     (lambda ()
       (interactive)
       (dired-sort-other (concat dired-listing-switches
                                 ,switch
                                 (if kid-dired-sort-reverse
                                     "r"
                                   "")
                                 (if kid-dired-sort-recursive
                                     "R"
                                   ""))))))
(defmacro kid-dired-define-toggle (key var)
  `(define-key dired-mode-map ,(concat "s" key)
     (lambda ()
       (interactive)
       (setq ,var (not ,var))
       (message "%s %s."
                (get ',var 'variable-documentation)
                (if ,var
                    "enabled"
                  "disabled")))))

;;;;;;;;;;;;;;;;;;;;  local keybind  ;;;;;;;;;;;;;;;;;;;;
(define-key dired-mode-map (kbd ";") 'dired-view-minor-mode-toggle)
(define-key dired-mode-map (kbd "C-s") 'dired-isearch-forward)
(define-key dired-mode-map (kbd "C-r") 'dired-isearch-backward)
(define-key dired-mode-map (kbd "M-C-s") 'dired-isearch-forward-regexp)
(define-key dired-mode-map (kbd "M-C-r") 'dired-isearch-backward-regexp)

;;;;;;;;;;;;;;;;;;;;  junk  ;;;;;;;;;;;;;;;;;;;;
;;(dired-details-install)
